package cn.tedu.hhmc.disease.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.tedu.hhmc.base.response.JsonResult;
import cn.tedu.hhmc.disease.pojo.entity.Disease;
import cn.tedu.hhmc.disease.pojo.vo.DiseaseVO;

import cn.tedu.hhmc.disease.service.DiseaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 疾病种类Controller
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@Slf4j
@RestController
@RequestMapping("/hhmc/disease")
public class DiseaseController
{
    @Autowired
    private DiseaseService diseaseService;

    /**
     * 查询疾病种类列表
     */
    @GetMapping("/list")
    public JsonResult list()
    {
        log.debug("查询疾病种类列表,参数:无");
        List<DiseaseVO> list = diseaseService.selectDiseaseList(new Disease());
        return JsonResult.ok(list);
    }


    /**
     * 获取疾病种类详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getInfo(@PathVariable("id") Long id)
    {
        return JsonResult.ok(diseaseService.selectDiseaseById(id));
    }

    /**
     * 新增疾病种类
     */
    @PostMapping
    public JsonResult add(@RequestBody Disease disease)
    {
        diseaseService.insertDisease(disease);
        return JsonResult.ok();
    }

    /**
     * 修改疾病种类
     */
    @PutMapping
    public JsonResult edit(@RequestBody Disease disease)
    {
        diseaseService.updateDisease(disease);
        return JsonResult.ok();
    }

    /**
     * 删除疾病种类
     */
	@DeleteMapping("/{ids}")
    public JsonResult remove(@PathVariable Long[] ids)
    {
        diseaseService.deleteDiseaseByIds(ids);
        return JsonResult.ok();
    }
}
